package com.sporadic.desk.controller;

import com.sporadic.desk.pojo.MTable;
import com.sporadic.desk.service.MTableService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import vo.ResponseData;

import java.util.List;
import java.util.Map;

/**
 * @program: sporadic
 * @description:
 * @author: LHD   QQ:1727865856
 * @create: 2019-10-22 15:14
 **/
@RestController
@CrossOrigin(value = "http://localhost:8080")
public class MTableController {
    @Autowired
    private MTableService mTableService;

    @GetMapping("/querytable")
    public ResponseData<List<MTable>> queryTable(Integer mid, Integer tableAreaId) {
        List<MTable> tables = mTableService.queryTable(mid, tableAreaId);
        return new ResponseData<>(tables);
    }

    @GetMapping("/updateTabelStatus")
    public ResponseData<Boolean> updateTable(Integer mid, Integer tid) {
        boolean b = mTableService.updateTableStatus(mid, tid, 4);
        if (b) {
            return new ResponseData<>(null);
        } else {
            return new ResponseData<>(null, "修改失败");
        }
    }
    @GetMapping("/queryTableBymidAndtableNum")
    public ResponseData<Map<String,Object>> queryTableBymidAndtableNum(Integer mid, String tableName){
        return mTableService.queryTableBymIdAndTableNum(mid, tableName);
    }
}
